From: Tim Deegan Date: Mon, 23 May 2011 17:35:32 +0000 (+0100) Subject: drivers/passthrough: fix error paths in pci_add_device*() X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~10326 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=cd06c7d669ea3d3716cb7e539148b9d4cf66e46f;p=xen.git drivers/passthrough: fix error paths in pci_add_device*() When a device can't be allocated to dom0 by the IOMMU, don't leave dom0 in the "domain" field. It causes pci_remove_device() to crash trying to remove the dev from the domain's list of devices (and was probably the wrong thing to do anyway). Signed-off-by: Tim Deegan --- diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c index e30cd950a3..d3f5e8fda8 100644 --- a/xen/drivers/passthrough/pci.c +++ b/xen/drivers/passthrough/pci.c @@ -158,7 +158,10 @@ int pci_add_device(u8 bus, u8 devfn) pdev->domain = dom0; ret = iommu_add_device(pdev); if ( ret ) + { + pdev->domain = NULL; goto out; + } list_add(&pdev->domain_list, &dom0->arch.pdev_list); pci_enable_acs(pdev); @@ -222,7 +225,10 @@ int pci_add_device_ext(u8 bus, u8 devfn, struct pci_dev_info *info) pdev->domain = dom0; ret = iommu_add_device(pdev); if ( ret ) + { + pdev->domain = NULL; goto out; + } list_add(&pdev->domain_list, &dom0->arch.pdev_list); pci_enable_acs(pdev);